package com.statistics.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.statistics.mapper.VisualStatisticsMapper;
import com.statistics.service.VisualStatisticsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * VisualStatisticsServiceImpl
 *
 * @author chenyy
 * &#064;date 2025/3/4 17:00
 */
@Service
public class VisualStatisticsServiceImpl implements VisualStatisticsService {
    @Resource
    private VisualStatisticsMapper visualStatisticsMapper;

    @Override
    public JSONObject getZxStatistics() {
        return visualStatisticsMapper.getZxStatistics();
    }

    @Override
    public JSONObject getHxStatistics() {
        return visualStatisticsMapper.getHxStatistics();
    }

    @Override
    public JSONObject getAchieveStats() {
        return visualStatisticsMapper.getAchieveStats();
    }

    @Override
    public JSONObject getAcadAchieveStats() {
        return visualStatisticsMapper.getAcadAchieveStats();
    }

    @Override
    public JSONObject getTotalResearchers() {
        return visualStatisticsMapper.getTotalResearchers();
    }

    @Override
    public List<JSONObject> getFiveYProjectsStats() {
        return visualStatisticsMapper.getFiveYProjectsStats();
    }

    @Override
    public List<JSONObject> getResearchFundingTop5() {
        List<JSONObject> researchFundingTop5 = visualStatisticsMapper.getResearchFundingTop5();
        for (JSONObject json : researchFundingTop5) {
            String unitId = json.getString("unitId");
            String income = visualStatisticsMapper.getIncomeByUnitId(unitId);
            json.put("income", income);
        }
        return researchFundingTop5;
    }

    @Override
    public List<JSONObject> getFiveYPaperStats() {
        return visualStatisticsMapper.getFiveYPaperStats();
    }

    @Override
    public JSONObject getProjectLevelStats() {
        return visualStatisticsMapper.getProjectLevelStats();
    }

    @Override
    public JSONObject getProjectExpenditure() {
        return visualStatisticsMapper.getProjectExpenditure();
    }

    @Override
    public JSONObject getProjectFundsReceived() {
        return visualStatisticsMapper.getProjectFundsReceived();
    }

    @Override
    public List<JSONObject> getFiveYPatentStats() {
        return visualStatisticsMapper.getFiveYPatentStats();
    }

    @Override
    public List<JSONObject> getUnitAchievementStatsTop5() {
        return visualStatisticsMapper.getUnitAchievementStatsTop5();
    }

    @Override
    public List<JSONObject> getFiveYTotalAchievement() {
        return visualStatisticsMapper.getFiveYTotalAchievement();
    }

    @Override
    public List<JSONObject> getFiveYHonorStats() {
        return visualStatisticsMapper.getFiveYHonorStats();
    }
}